<template>
  <div class="article">
    <Header class="header"></Header>
    <Main class="main"></Main>
  </div>
</template>

<script>
import Header from "@/components/article/Header";
import Main from "@/components/article/Main";
import { mapState } from "vuex";
import { getSessionStorage, parse } from "@/utils/utils";
export default {
  name: "WriteArticle",
  components: {
    Header,
    Main,
  },
  computed: {
    ...mapState(["isLogin"]),
  },
  mounted() {
    if (this.isLogin) {
      let data = getSessionStorage("tempArticleMsg");
      if (data) {
        data = parse(data);
        data;
        this.$bus.$emit("titleFull", data.title);
        this.$bus.$emit("articleFull", data.article);
        // 给header提供article, 否则发不了文章
        this.$bus.$emit("articleChange", data.article);
        this.$bus.$emit("getArticleImg", data.article_img);
        this.$bus.$emit("emitVisible", true); // 先显示才能让tag和sort有值
        Promise.resolve()
          .then(() => {
            this.$bus.$emit("getSort", data.sort);
          })
          .then(() => {
            this.$bus.$emit("getTag", data.tag);
          });
      }
    }
  },
};
</script>

<style lang="scss" scoped>
.article {
  height: 100%;
}
</style>